<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">

	<head>
		<title>在线正则表达式测试</title>
		<meta charset="UTF-8" />
		<meta http-equiv="Content-Language" content="zh-CN" />
		<meta name="keywords" content="开源中国 在线工具,ostools,jsbin,加密/解密，Markdown,less,java api,php api,node.js api,QR Code" />
		<meta name="description" content="开源中国在线工具,ostools为开发设计人员提供在线工具，提供jsbin在线 CSS、JS 调试，在线 Java API文档,在线 PHP API文档,在线 Node.js API文档,Less CSS编译器，MarkDown编译器等其他在线工具" />
		<link rel="shortcut icon" href="http://tool.oschina.net/img/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="http://tool.oschina.net/css/basic.css?20120912" type="text/css" />
		<script type="text/javascript" src='http://tool.oschina.net/js/jquery/jquery-1.7.2.js'></script>
		<script type="text/javascript" src='http://tool.oschina.net/js/jquery/jquery.cookies.2.2.0.min.js'></script>
		<link rel="stylesheet" href='http://tool.oschina.net/js/bootstrap/css/bootstrap.min.css' />
		<script src='http://tool.oschina.net/js/bootstrap/js/bootstrap.min.js'></script>
		<!--http://tool.oschina.net/js/bootstrap/js/bootstrap.min.js-->
	</head>

	<body>
		<!--     头部header开始    -->
		<div id="header">
			<div class="wrapper">
				<div id="mainSearch">

					<!-- Put the following javascript before the closing </head> tag. -->
					<style>
						.go_search {
							width: 300px;
						}
						
						.go_search .gsc-input td,
						.go_search .gsc-input tddiv {
							padding: 0 0 0 0;
							margin: 0 0 0 0;
							height: 23px;
						}
						
						.go_search .gsc-input input:focus {
							border: none;
						}
						
						.go_search .gsc-input input {
							border: none;
							height: 23px;
							width: 100%;
							padding: 0px;
							border: none;
							margin: 0px;
							height: auto;
							outline: none;
							-webkit-box-shadow: none;
							-moz-box-shadow: none;
							box-shadow: none;
							background-image: url(../img/google_custom_search_watermark.gif?20140625);
							background-color: rgb(255, 255, 255);
							background-position: 0% 50%;
							background-repeat: no-repeat no-repeat;
						}
					</style>

					<div class="go_search">
						<!-- Place this tag where you want the search box to render -->
					</div>
				</div>
				<div id="logo" class="texthidden" onclick="javascript:location.href='/'">
					<h1>开源中国在线工具</h1>
				</div>
			</div>
		</div>
		<!--     头部header结束    -->
		<div class="wrapper">
			<script type="text/javascript" src="http://tool.oschina.net/js/ad/tag.js?date=20140625"></script>

		</div>
		<style>
			.topBar {
				margin: 10px 0 10px 0;
			}
			
			.bottomBar {
				margin: 10px 0 10px 0;
			}
			
			#mainContent textarea {
				width: 650px;
				height: 150px;
			}
			
			#mainContent ul {
				margin-top: 10px;
			}
			
			#right_area li {
				height: 40px;
				font-size: 13pt;
			}
		</style>
		<div id="mainContent" class="wrapper clearfix">
			<div class="toolName">在线正则表达式测试
				<a data-toggle="modal" href="#advice" style="float:right;text-decoration:none;"><span class="badge badge-important"><i class="icon-envelope icon-white"></i> Feedback</span></a>
			</div>
			<div class="row-fluid">
				<div class="span8">
					<div class="topBar">
						<textarea id="textSour" placeholder="在此输入待匹配文本"></textarea>
					</div>
					<div class="operateTB">
						<form class="well form-inline">
							<div class="input-prepend">
								<span class="add-on">正则表达式</span><input type="text" id="textPattern" placeholder="在此输入正则表达式" class="input-xlarge"></input>
							</div>
							<label class="checkbox"><input type="checkbox" value="global" checked="checked" id="optionGlobal" name="optionGlobl"/>全局搜索</label>
							<label class="checkbox"><input type="checkbox" value="ignoreCase" id="optionIgnoreCase" name="optionIgnoreCase"/>忽略大小写</label>
							<a onclick="return onMatch();" class="btn btn-primary"><i class="icon-chevron-down icon-white"></i>测试匹配</a>
						</form>
					</div>
					<div class="bottomBar">
						<div class="title">匹配结果：</div>
						<textarea readonly="readonly" id="textMatchResult"></textarea>
					</div>
					<div class="operateTB">
						<form class="well form-inline">
							<div class="input-prepend">
								<span class="add-on">替换文本</span><input type="text" id="textReplace" class="input-xlarge" placeholder="在此输入替换文本"></input>
							</div>
							<a onclick="return onReplace()" class="btn btn-primary"><i class="icon-chevron-down icon-white"></i>替换</a>
						</form>
					</div>
					<div class="bottomBar">
						<div class="title">替换结果：</div>
						<textarea readonly="readonly" id="textReplaceResult"></textarea><br/>
					</div>
				</div>
				<div class="span4" id="right_area">
					<ul class="nav nav-list well">
						<li class="nav-header"><i class="icon-list icon-black"></i>常用正则表达式</li>
						<li>
							<a href="#" title="[\u4e00-\u9fa5]">匹配中文字符</a>
						</li>
						<li>
							<a href="#" title="[^\x00-\xff]">匹配双字节字符(包括汉字在内)</a>
						</li>
						<li>
							<a href="#" title="\n\s*\r">匹配空白行</a>
						</li>
						<li>
							<a href="#" title="[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?">匹配Email地址</a>
						</li>
						<li>
							<a href="#" title="[a-zA-z]+://[^\s]*">匹配网址URL</a>
						</li>
						<li>
							<a href="#" title="\d{3}-\d{8}|\d{4}-\{7,8}">匹配国内电话号码</a>
						</li>
						<li>
							<a href="#" title="[1-9][0-9]{4,}">匹配腾讯QQ号</a>
						</li>
						<li>
							<a href="#" title="[1-9]\d{5}(?!\d)">匹配中国邮政编码</a>
						</li>
						<li>
							<a href="#" title="^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$">匹配18位身份证号</a>
						</li>
						<li>
							<a href="#" title="([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8])))">匹配(年-月-日)格式日期</a>
						</li>
						<li>
							<a href="#" title="^[1-9]\d*$">匹配正整数</a>
						</li>
						<li>
							<a href="#" title="^-[1-9]\d*$">匹配负整数</a>
						</li>
						<li>
							<a href="#" title="^-?[1-9]\d*$">匹配整数</a>
						</li>
						<li>
							<a href="#" title="^[1-9]\d*|0$">匹配非负整数（正整数 + 0）</a>
						</li>
						<li>
							<a href="#" title="^-[1-9]\d*|0$">匹配非正整数（负整数 + 0）</a>
						</li>
						<li>
							<a href="#" title="^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$">匹配正浮点数</a>
						</li>
						<li>
							<a href="#" title="^-[1-9]\d*\.\d*|-0\.\d*[1-9]\d*$">匹配负浮点数</a>
						</li>
					</ul>
				</div>
			</div>
		</div>
		<!-- /container -->
		<script language="javascript">
			$(document).ready(function() {
				$("#right_area li a").click(function() {
					$("#textPattern").val($(this).attr("title"));
					onMatch();
				});
			});

			function setVisible(idElement, visible) {
				var obj = document.getElementById(idElement);
				obj.style.visibility = visible ? "visible" : "hidden";
			}

			function isValidFields() {
				var textSour = document.getElementById("textSour");
				if(null == textSour.value || textSour.value.length < 1) {
					textSour.focus();
					alert("请输入待匹配文本");
					return false;
				}
				var textPattern = document.getElementById("textPattern");
				if(null == textPattern.value || textPattern.value.length < 1) {
					textPattern.focus();
					alert("请输入正则表达式");
					return false;
				}
				return true;
			}

			function buildRegex() {
				var op = "";
				if(document.getElementById("optionGlobal").checked) op = "g";
				if(document.getElementById("optionIgnoreCase").checked) op = op + "i";
				return new RegExp(document.getElementById("textPattern").value, op);
			}

			function onMatch() {
				if(!isValidFields())
					return false;
				document.getElementById("textMatchResult").value = "";
				var regex = buildRegex();
				var result = document.getElementById("textSour").value.match(regex);
				
				if(null == result || 0 == result.length) {
					document.getElementById("textMatchResult").value = "（没有匹配）";
					return false;
				}
				if(document.getElementById("optionGlobal").checked) {
					var strResult = "共找到 " + result.length + " 处匹配：\r\n";
					for(var i = 0; i < result.length; ++i) strResult = strResult + result[i] + "\r\n";
					document.getElementById("textMatchResult").value = strResult;
				} else {
					document.getElementById("textMatchResult").value = "匹配位置：" + regex.lastIndex + "\r\n匹配结果：" + result[0];
				}
				return true;
			}

			function onReplace() {
				var str = document.getElementById("textSour").value;
				var regex = buildRegex();
				document.getElementById("textReplaceResult").value = str.replace(regex,function(){
					console.log(arguments);
				})//document.getElementById("textReplace").value);
			}

			function reset() {
				$("#textSour").val("");
				$("#textPattern").val("");
				$("#textMatchResult").val("");
				$("#textReplace").val("");
				$("#textReplaceResult").val("");
			}
		</script>
		<!--     尾部footer开始    -->
		<div id="footer">
			<p class="wrapper">
				在线工具 由
				<a href="http://www.oschina.net/" target="_blank">开源中国</a> 所有 |
				<a href="http://weibo.com/oschina2010" target="_blank">@新浪微博</a> |
				<a href="http://www.aliyun.com/" target="_blank">阿里云</a>提供服务器和带宽 |
				<a data-toggle="modal" href="#advice">意见反馈</a> |
				<a href="http://www.miitbeian.gov.cn/" target="_blank">粤ICP备12009483号-5</a> |
				<script src="http://s9.cnzz.com/stat.php?id=4420195&web_id=4420195&show=pic1" language="JavaScript"></script>
			</p>
		</div>
		<!--     尾部footer结束    -->
		<div class="modal hide fade" id="advice" style="display:none;">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">×</button>
				<h3>在线正则表达式测试</h3>
			</div>
			<div class="modal-body">
				<p>在此填写您的意见信息：</p>
				<form class='well' id='advice_form'>
					<input id="tool_name_f" type='hidden' name='tool_name' value='在线正则表达式测试' />
					<div class="input-prepend">
						<span class="add-on">Email邮箱:</span><input class="input-xlarge" type="text" id="advice_email" name="email" placeholder="在此输入您的Email" onblur="javascript:verifyEmail();" title="Email邮箱" /><span style="color:#A00" id="email_error"> (必填) </span>
					</div>

					<label class="textarea">您的建议和意见：<br><textarea name="content" id="advice_content" style="width:480px;height:150px" placeholder="在此填写对  在线正则表达式测试 的意见和建议"></textarea></label>
					<label class="input">验证码：
			<img style="margin-bottom:9px;" src="http://tool.oschina.net/action/jsbin/captcha" id="captcha_code" height="30px" width="80px" onclick="this.src = '/action/jsbin/captcha?'+new Date().getTime();"/>
			<input type="text" id="captcha_input" onkeyup="document.getElementById('verifyCode').value=this.value;" style="height:20px;width:30px;"/>
			<input id="verifyCode" name="verifyCode" type="hidden"/></label>
				</form>
			</div>
			<div class="modal-footer">
				<a href="#" class="btn" data-dismiss="modal">取消</a>
				<a href="#" class="btn btn-primary" id="advice_submit" disabled='disabled'>提交建议</a>
			</div>
		</div>
		<script>
			function verifyEmail() {
				if(null == $("#advice_email").val().match(/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/)) {
					$("#email_error").html(" email输入错误 ");
					$("#advice_email").focus();
				} else {
					$("#email_error").html("<i class='icon-ok'></i>");
					$("#advice_submit").removeAttr("disabled");
				}
			}
			$(document).ready(function() {
				$("#advice_submit").click(function() {
					$.post("/action/advice/add_advice", {
							tool_name: $("#tool_name_f").val(),
							email: $("#advice_email").val(),
							content: $("#advice_content").val(),
							verifyCode: $("#verifyCode").val()
						},
						function(result) {
							var m = eval('(' + result + ')');
							if("ok" == m.msg) {
								alert("谢谢您的建议，我们会参考您的建议使ostools变得更好！");
								$('#advice').modal('hide');
								$("#captcha_code").attr("src", '/action/jsbin/captcha?' + new Date().getTime());
							} else {
								alert(m.msg);
							}
						});
				});
			});
		</script>
		<a class="bshareDiv" href="http://www.bshare.cn/share">分享按钮</a>
		<script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/buttonLite.js#uuid=&amp;style=3&amp;fs=4&amp;textcolor=#fff&amp;bgcolor=#06C&amp;text=分享到&amp;pophcol=1"></script>
	</body>

</html>
<!-- Generated by OSCTools.NET (Fri Dec 30 15:54:46 CST 2016) 3ms -->